package com.leyou.search.web;

import com.leyou.common.vo.PageResult;
import com.leyou.search.pojo.Goods;
import com.leyou.search.pojo.SearchRequest;
import com.leyou.search.service.SearchService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * description: 搜索接口
 * @author 朱正磊
 * @date 2021-04-09 00:50:44
 */
@RestController
public class SearchController {

    @Resource
    private SearchService searchService;

    /**
     * description: 商品搜索功能
     * @author 朱正磊
     * @date 2021-04-09 00:53:12
     * @param searchRequest 搜索请求参数
     * @return 返回商品分页数据
     */
    @PostMapping("page")
    public ResponseEntity<PageResult<Goods>> search(@RequestBody SearchRequest searchRequest) {
        return ResponseEntity.ok(searchService.search(searchRequest));
    }

}
